import java.util.PriorityQueue;
class MyTimerTask implements Comparable<MyTimerTask>{
    private long time;
    Runnable runnable;

    public MyTimerTask( Runnable runnable,long time) {
        this.time = System.currentTimeMillis()+time;
        this.runnable = runnable;
    }
    public void run(){
        runnable.run();
    }
public long gettime(){
        return time;
}
    @Override
    public int compareTo(MyTimerTask o) {
        return (int)(this.time-o.time);
    }
}
public class MyTimer {
    Thread t = null;
    PriorityQueue<MyTimerTask>  queue = new PriorityQueue();
    public void schedule(Runnable runnable,long time){
MyTimerTask task = new MyTimerTask(runnable,time);
queue.offer(task);
    }
  public MyTimer(){
t = new Thread(()->{
    while(true){
        if(queue.isEmpty()){
            continue;
        }
        MyTimerTask task = queue.peek();
long curtime = System.currentTimeMillis();
if(curtime>=task.gettime()){
    queue.poll();
}
else {
    continue;
}
    }
});
  }

}
